<template>
	<view class="index">
		<!-- 头部组件 -->
		<view style="background-color: #fff;">
			<NavBar title="安全模式"></NavBar>
		</view>
		<view class="add" @tap="navTo">
			<image src="@/static/img/plus_account.png" mode="widthFix"></image>
			<text>新增</text>
		</view>
		<view class="contentList">
			<view v-for="item,index in contentList" :key="index" class="contentItem">
				<text>设置{{ item.number }}</text>
				<view class="buttonGroup">
					<view class="buttonItem cancel">取消</view>
					<view class="buttonItem delete">删除</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import NavBar from '@/components/navBar.vue'

	const contentList = ref<any[]>([
		{ number: '10001' },
		{ number: '10002' },
		{ number: '10003' },
		{ number: '10004' },
		{ number: '10005' },
		{ number: '10006' },
	])

	// 跳转值新增页面，并携带本页面现有列表数据渲染
	const navTo = () : void => {
		const jsonData = JSON.stringify(contentList.value);
		const encodedData = encodeURIComponent(jsonData);

		// 建议使用状态管理器或新增页面重新调用列表接口
		uni.navigateTo({ url: `/pages/my/add?data=${encodedData}` })
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100vh;
		background-color: #f4f6fa;

		.add {
			height: 96rpx;
			border-top: 1px solid #eee;
			background-color: #fff;
			padding-left: 32rpx;
			display: flex;
			align-items: center;

			text {
				color: #6B64D3;
				font-weight: 600;
			}

			image {
				width: 42rpx;
				margin-right: 24rpx;
			}
		}

		.contentList {
			padding: 24rpx 23rpx 0 25rpx;

			.contentItem {
				width: 702rpx;
				height: 122rpx;
				background: #FFFFFF;
				border-radius: 24rpx;
				padding: 0 24rpx;
				margin-bottom: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				text {
					font-size: 32rpx;
					color: #262626;
					font-weight: 600;
				}

				.buttonGroup {
					display: flex;
					align-items: center;

					.buttonItem {
						width: 120rpx;
						height: 58rpx;
						text-align: center;
						line-height: 58rpx;
						font-size: 28rpx;
						color: #262626;
						border-radius: 8rpx 8rpx 8rpx 8rpx;
					}

					.cancel {
						background: #F4F6FA;
						margin-right: 16rpx;
					}

					.delete {
						background: #FFDED3;
						color: #FF263F;
					}
				}
			}
		}

	}
</style>